const mongoose = require('mongoose');

const productSchema = new mongoose.Schema({
  name: {
    type: String,
    required: true
  },
  type: {
    type: String,
    required: true
  },
  description: {
    type: String
  },
  is_available: {
    type: Boolean,
    default: true
  },
  price: {
    type: Number,
    required: true
  },
  village_collective_id: {
    type: Number,
    required: true
  },
  inventory: {
    type: Number,
    default: 0
  },
  url: {
    type: String
  }
}, {
  timestamps: true // 自动添加 createdAt 和 updatedAt 字段
});

const Product = mongoose.model('Product', productSchema);

module.exports = Product;